package com.example.homework3mybatis.controller;


import com.example.homework3mybatis.entity.Employee;
import com.example.homework3mybatis.service.EmployeeService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController()

public class EmployeeController {

    @Autowired
    EmployeeService employeeService;

    @GetMapping("/emp/{id}")
    public Employee getEmp(@PathVariable("id") String id) {
        return employeeService.findOneById(id);
    }

    @GetMapping("/emps")
    public List<Employee> findAllEmps() {
        return employeeService.findAll();
    }

    @GetMapping("/employees")
    public PageInfo<Employee> findByPage(@RequestParam(defaultValue = "1") int pageNum,
                                         @RequestParam(defaultValue = "10") int pageSize) {
        return employeeService.findByPage(pageNum, pageSize);
    }

}